import type { VxeGridProps } from '#/adapter/vxe-table';

import { DictEnum } from '@vben/constants';

export const basicInfoSchema: DetailsModalSchemaGetter = () => [
  {
    label: '企业名称',
    fieldName: 'name',
    copy: true,
  },
  {
    label: '企业简称',
    fieldName: 'alias',
    copy: true,
  },
  {
    label: '企业类型',
    fieldName: 'type',
    dictEnum: DictEnum.COMPANY_TYPE,
  },
  {
    label: '所属来源',
    fieldName: 'sourceName',
  },
  {
    label: '是否海外',
    fieldName: 'isAbroad',
    dictEnum: DictEnum.BUSINESS_YES_NO,
    dictEnumFormatNumber: true,
  },
  {
    label: '企业地址',
    fieldName: 'countryCode',
    copy: (info: any) => {
      if (info.isAbroad === 1) {
        return `${info.address} ${info.countryName}`;
      }

      return `${info.countryName}${info.provinceName}${info.cityName}${info.districtName}${info.address}`;
    },
    slots: {
      default: (info) => {
        if (info.isAbroad === 1) {
          return (
            <span>
              {info.address} {info.countryName}
            </span>
          );
        }
        return (
          <span>
            {info.countryName}
            {info.provinceName}
            {info.cityName}
            {info.districtName}
            {info.address}
          </span>
        );
      },
    },
  },
  {
    label: '网址',
    fieldName: 'website',
    url: true,
    copy: true,
  },
  {
    label: '企业标签',
    fieldName: 'labels',
    custom: true,
    span: 2,
  },
  {
    label: '公司简介',
    fieldName: 'introduction',
    textWrap: true,
    copy: true,
    span: 2,
  },
  {
    label: '备注',
    fieldName: 'remark',
    textWrap: true,
    span: 2,
  },
  {
    label: '跟进人',
    fieldName: 'followUpName',
  },
];

export const businessInfoSchema: DetailsModalSchemaGetter = () => [
  { label: '企业名称', fieldName: 'name', copy: true },
  { label: '曾用名', fieldName: 'historyNames', copy: true },
  { label: '简称', fieldName: 'alias', copy: true },
  {
    label: '所在地区',
    fieldName: 'city',
    copy: (info: any) => {
      return `${info.city || ''}${info.district || ''}`;
    },
    slots: {
      default: (info) => {
        return (
          <span>
            {info.city}
            {info.district}
          </span>
        );
      },
    },
  },
  { label: '法定代表人', fieldName: 'legalPersonName', copy: true },
  { label: '统一社会信用代码', fieldName: 'creditCode', copy: true },
  { label: '公司类型', fieldName: 'companyOrgType', copy: true },
  { label: '组织机构代码', fieldName: 'orgNumber', copy: true },
  { label: '经营状态', fieldName: 'regStatus' },
  { label: '注册号', fieldName: 'regNumber', copy: true },
  { label: '成立日期', fieldName: 'estiblishTime', copy: true },
  {
    label: '营业期限',
    fieldName: 'fromTime',
    slots: {
      default: (info) => {
        return (
          <span>
            {info.fromTime} ~ {info.toTime}
          </span>
        );
      },
    },
  },
  { label: '注册资本', fieldName: 'regCapital', copy: true },
  { label: '实缴资本', fieldName: 'actualCapital', copy: true },
  { label: '登记机关', fieldName: 'regInstitute', copy: true },
  { label: '核准日期', fieldName: 'approvedTime', copy: true },
  { label: '公司规模', fieldName: 'staffNumRange' },
  { label: '参保人数', fieldName: 'socialStaffNum' },
  // { label: '英文名', fieldName: 'name', copy: true },
  { label: '主要行业', fieldName: 'industry', copy: true },
  { label: '国标行业分类', fieldName: 'category', copy: true, span: 2 },
  { label: '注册地址', fieldName: 'regLocation', copy: true, span: 2 },
  { label: '经营范围', fieldName: 'businessScope', copy: true, span: 2 },
];

export const listingInfoSchema: DetailsModalSchemaGetter = () => [
  { label: '股票名', fieldName: 'bondName', copy: true },
  { label: '股票号', fieldName: 'bondNum', copy: true },
  { label: '股票类型', fieldName: 'bondType' },
  { label: '股票曾用名', fieldName: 'usedBondName', copy: true },
];

export const businessCustomerColumns: VxeGridProps['columns'] = [
  {
    title: '客户',
    field: 'clientName',
    minWidth: 180,
    slots: { default: 'clientName' },
    showOverflow: true,
  },
  {
    title: '销售占比',
    field: 'ratio',
  },
  {
    title: '销售金额(万元)',
    field: 'amt',
  },
  {
    title: '报告期',
    field: 'announcementDate',
  },
  {
    title: '数据来源',
    field: 'dataSource',
  },
  {
    title: '关联关系',
    field: 'relationShip',
  },
];

export const businessSupplierColumns: VxeGridProps['columns'] = [
  {
    title: '供应商',
    field: 'supplierName',
    minWidth: 180,
    slots: { default: 'supplierName' },
  },
  {
    title: '采购占比',
    field: 'ratio',
  },
  {
    title: '采购金额',
    field: 'amt',
  },
  {
    title: '报告期',
    field: 'announcementDate',
  },
  {
    title: '数据来源',
    field: 'dataSource',
  },
  {
    title: '关联关系',
    field: 'relationShip',
  },
];

export const groupMemberColumns: VxeGridProps['columns'] = [
  {
    title: '集团/成员名称',
    field: 'cname',
    minWidth: 180,
    // slots: { default: 'cname' },
    treeNode: true,
  },
  {
    title: '法定代表人',
    field: 'legalPersonName',
  },
  {
    title: '登记状态',
    field: 'regStatus',
  },
  {
    title: '成立日期',
    field: 'establishTime',
  },
  {
    title: '注册资本',
    field: 'regCapitalStr',
  },
];
